#include "dma_config.h"

void my_dma_software_init(uint32_t src, uint32_t dst, uint32_t size)
{
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
    DMA_InitTypeDef DMA_InitStructure;
    DMA_InitStructure.DMA_PeripheralBaseAddr=src;
    DMA_InitStructure.DMA_PeripheralDataSize=DMA_PeripheralDataSize_Byte;
    DMA_InitStructure.DMA_PeripheralInc=DMA_PeripheralInc_Enable;
    DMA_InitStructure.DMA_MemoryBaseAddr=dst;
    DMA_InitStructure.DMA_MemoryDataSize=DMA_MemoryDataSize_Byte;
    DMA_InitStructure.DMA_MemoryInc=DMA_MemoryInc_Enable;
    DMA_InitStructure.DMA_DIR=DMA_DIR_PeripheralSRC; //peripheral->memory
    DMA_InitStructure.DMA_BufferSize=size;
    DMA_InitStructure.DMA_M2M=DMA_M2M_Enable;
    DMA_InitStructure.DMA_Mode=DMA_Mode_Normal; //normal mode
    DMA_InitStructure.DMA_Priority=DMA_Priority_Medium;

    DMA_Init(DMA1_Channel1,&DMA_InitStructure);
    DMA_Cmd(DMA1_Channel1,ENABLE);
}